const nodemailer = require('nodemailer');

const sendEmail = async (req, res) => {
   const transporter = nodemailer.createTransport({
      service: 'qq',
      port: 465,
      secure: true,
      auth: {
         user: process.env.EMAIL_ACCOUNT,
         pass: process.env.EMAIL_PASSWORD,
      },
   });

   const info = await transporter
      .sendMail({
         from: `"YEYE" <${process.env.EMAIL_ACCOUNT}>`, // sender address
         to: 'xxxx', // list of receivers
         subject: 'Hello ✔', // Subject line
         text: 'Hello world?', // plain text body
         html: '<b>Hello world?</b>', // html body
      })
      .catch((err) => {
         throw err
      });
   res.status(200).json({
      info,
   });
};

module.exports = sendEmail;
